package com.yyx.springcloud.service.impl;

import com.yyx.springcloud.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * ClassName: MessageProviderImpl
 * Package: com.yyx.springcloud.service.impl
 * Description:
 *
 * @Author: yyx
 * @Create: 2025/7/28 - 15:22
 */
@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {
    @Autowired
    private MessageChannel output; // 消息发送管道
    @Override
    public String send() {
        String serial = UUID.randomUUID().toString().replace("-","");
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("*****serial: "+serial);
        return "";
    }
}
